package com.example.server.Contr;

import com.example.server.Service.PlaceService;
import com.example.server.entity.Lunboplace;
import com.example.server.entity.Place;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/place")
public class PlaceContr {
@Autowired
    private PlaceService placeService;
@RequestMapping("/getallplace")
public List<Place> getplace(){
    return placeService.getallplace();
}
@RequestMapping("/Lunboplace")
    public List<Lunboplace> getlunbo(){
    return placeService.getlunbo();
}
@RequestMapping("/addlunboplace")
public boolean addlunbo(@RequestParam("place_id") int id){
    return placeService.addlunbo(id);
}
@RequestMapping("/selectlunboplace")
public int selectlunboplace(@RequestParam("place_id") int id){
    return placeService.selectlunbopla(id);
}


    @RequestMapping("deletelunboplace")
public int deletelunbo(@RequestParam("place_id") String id){
    return placeService.deletelunbo(id);
}
@RequestMapping("/smallsearchplaces")//山林，城市，海洋，乡村
    public List<Place> getplace(@RequestParam("Type") String type){
    return placeService.smallfindby(type);
}
@RequestMapping("/search/{type}")
    public List<Place> getplace(@PathVariable String type, @RequestParam("text") String searchtext){
    System.out.println(type+searchtext);
    return placeService.getsearch(type,searchtext);
}
@RequestMapping("/uidgetplace") //通过uid查询收藏地点全部信息。
    public List<Place> uidgetplace(@RequestParam("uid") String uid){
    return placeService.uidgetplace(uid);
}
@RequestMapping("/adminselectplace")
    public int selectplace(){
    return placeService.getplace();
}
@RequestMapping("/deleteplace")
    public int delete(@RequestParam("placeid") int id){
    return placeService.deleteplace(id);
}
}
